﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MangoMes.Write.API.Applications.Login;
using MediatR;

namespace ManagoMes.Read.API.Applications.ProductionScheduling
{
    public class WorkStationbackHandler : IRequestHandler<WorkStationbackCommond, ResultsDTO<WorkStationSto>>
    {

        private readonly IBateRepository<WorkStationSto> _WorkStationSto;
        private readonly Logincommonality _Logincommonality;

        public WorkStationbackHandler(IBateRepository<WorkStationSto> workStationSto, Logincommonality logincommonality)
        {
            _WorkStationSto = workStationSto;
            _Logincommonality = logincommonality;
        }

        public async Task<ResultsDTO<WorkStationSto>> Handle(WorkStationbackCommond request, CancellationToken cancellationToken)
        {

            var list = new ResultsDTO<WorkStationSto>() { Code = 0 };


            var str = "select * from workstation WHERE Workid=" + request.Workid + "";
            var Emptey = new WorkStationSto();
            DapperHelper dapperHelper = new DapperHelper();
            var putdata = _WorkStationSto.GetAll(str, Emptey, dapperHelper.MangoMesRead).ToList();

            var OperatorName = "123";
            var OperatorTime = DateTime.Now.ToString();
            var PerformOperation = "选择工作站";
            _Logincommonality.Loginaddget(OperatorName, OperatorTime, PerformOperation);


            list.Data = putdata;



            return list;


        }
    }
}
